import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router";
import { routes } from "@/router/routes";

// import HomeView from "@/views/HomeView.vue";

// const routes: Array<RouteRecordRaw> = [
//   { path: "/", component: HomeView },
// ];
const router = createRouter({
  history: createWebHistory(),
  routes
});

export default router;

/* 获取所有的路由 */
export const getAllRouter: Array<string> = [];
handleGetAllRouter(routes);
function handleGetAllRouter(routes: Array<RouteRecordRaw>) {
  if (!routes) return;
  for (let i = 0; i < routes.length; i++) {
    if (routes[i]?.children) {
      handleGetAllRouter(routes[i].children || []);
    } else {
      getAllRouter.push(routes[i].path);
    }
  }
}
